/*
 *  This file is part of Bracket Security
 *  Copyright 2011 David R. Smith
 *
 */
package asia.redact.bracket.security;

import asia.redact.bracket.util.SafeString;

/**
 * Wrapper for input which is to be decrypted.
 * 
 * @author Dave
 * @see SecurityTool
 */
public class DecryptParams {
	
	// the keystore alias of the X509 private key we'll use to decrypt the symmetric cipher key
	public final String alias; 
	
	// symmetric ciphered message, in armored Base64 URL-SAFE format
	public final SafeString encryptedMsg;
	
	// asymmetric ciphered key, in armored Base64 URL-SAFE format
	public final SafeString encryptedKey;
	
	public DecryptParams(String alias, SafeString encryptedKey, SafeString encryptedMsg) {
		super();
		this.alias = alias;
		this.encryptedMsg = encryptedMsg;
		this.encryptedKey = encryptedKey;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((alias == null) ? 0 : alias.hashCode());
		result = prime * result
				+ ((encryptedKey == null) ? 0 : encryptedKey.hashCode());
		result = prime * result
				+ ((encryptedMsg == null) ? 0 : encryptedMsg.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj == null) {
			return false;
		}
		if (!(obj instanceof DecryptParams)) {
			return false;
		}
		DecryptParams other = (DecryptParams) obj;
		if (alias == null) {
			if (other.alias != null) {
				return false;
			}
		} else if (!alias.equals(other.alias)) {
			return false;
		}
		if (encryptedKey == null) {
			if (other.encryptedKey != null) {
				return false;
			}
		} else if (!encryptedKey.equals(other.encryptedKey)) {
			return false;
		}
		if (encryptedMsg == null) {
			if (other.encryptedMsg != null) {
				return false;
			}
		} else if (!encryptedMsg.equals(other.encryptedMsg)) {
			return false;
		}
		return true;
	}
	
}
